package com.loong.common.enumerate;

import lombok.Getter;

/**
 * @Description: 手机充值状态
 * @Author: LiuQun
 * @Date: 2020/11/27 11:34
 */
@Getter
public enum PhoneChargeStatus {

    UN_KNOW_ERROR(-1,"un_know_error","未知错误"),
    PAID(1,"paid","支付成功未充值"),
    PENDING(2,"pending","充值中"),
    SUCCESS(3,"success","充值成功"),
    FAILED(4,"failed","充值失败"),
    REFUND(5,"refund","已退款"),
    WAIT_FOR_PAYMENT(6,"wait_for_payment","等待付款"),
    CLOSE_TRADE(7,"close_trade","交易关闭"),
    CANCEL_ORDER(8,"cancel_order","订单取消")
    ;
    private int code;
    private String name;
    private String desc;

    PhoneChargeStatus(int code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }


    /**
     * 根据状态名称获取对应的状态code
     * @param name 状态名称
     * @return 状态code值
     */
    public static int getPhoneChargeStatusCode(String name){
        PhoneChargeStatus chargeStatus;
        switch (name) {
            case "paid":
                chargeStatus = PhoneChargeStatus.PAID;
                break;
            case "pending":
                chargeStatus = PhoneChargeStatus.PENDING;
                break;
            case "success":
                chargeStatus = PhoneChargeStatus.SUCCESS;
                break;
            case "failed":
                chargeStatus = PhoneChargeStatus.FAILED;
                break;
            case "refund":
                chargeStatus = PhoneChargeStatus.REFUND;
                break;
            case "Wait_for_payment":
                chargeStatus = PhoneChargeStatus.WAIT_FOR_PAYMENT;
                break;
            case "close_trade":
                chargeStatus = PhoneChargeStatus.CLOSE_TRADE;
                break;
            case "cancel_order":
                chargeStatus = PhoneChargeStatus.CANCEL_ORDER;
                break;
            default:
                chargeStatus = PhoneChargeStatus.UN_KNOW_ERROR;
        }
        return chargeStatus.getCode();
    }

}
